package com.luzhikun.procinceAjax.servlet;

import com.luzhikun.procinceAjax.service.IPriFindService;
import com.luzhikun.procinceAjax.service.PriFIndServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "FindServlet", value = "/findServlet")
public class FindServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        System.out.println("------");

        // 获取请求的参数信息
        String priceid = request.getParameter("priid");
        // 格式化请求参数
        int priid=Integer.parseInt(priceid);

        // 创建Service对象传递数据
        IPriFindService is=new PriFIndServiceImp();
        String name=is.findPri(priid);
        // 获取结果
        PrintWriter out=response.getWriter();
        // 将结果交给异步对象
        out.println(name);

    }
}
